{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "73eb3bc4-6ac1-4b65-9a66-150441f95mp4 ==> 73eb3b.mp4\n",
      "0c22b9ad-df4b-45ef-8cf2-1d8267f13mp4 ==> 0c22b9.mp4\n",
      "bcba9310-f2a3-4083-9f90-cb1ae4e93mp4 ==> bcba93.mp4\n",
      "5d1160cd-2637-4e75-a7bd-0e84f077dmp4 ==> 5d1160.mp4\n",
      "ce73e9bc-a2d2-4f4e-a818-449681f84mp4 ==> ce73e9.mp4\n",
      "f82b5f12-c90f-42a3-ab9c-fe0288786mp4 ==> f82b5f.mp4\n",
      "6c968c3f-58c5-474f-aaa0-1c5d51da3mp4 ==> 6c968c.mp4\n",
      "f393ce7d-7214-4b1a-83ab-ed17520a6mp4 ==> f393ce.mp4\n",
      "8cb7e9ed-8aa2-4070-a07e-a236ba8e1mp4 ==> 8cb7e9.mp4\n",
      "30ade32c-5c0c-44cd-b068-b010be38cmp4 ==> 30ade3.mp4\n",
      "9ea97401-2906-468d-be77-e7b324754mp4 ==> 9ea974.mp4\n",
      "528e6895-7a23-40b3-8b54-736bd94c6mp4 ==> 528e68.mp4\n",
      "3018ec91-5b15-44cd-8620-6466ab847mp4 ==> 3018ec.mp4\n",
      "19503be2-054b-4a3c-a92c-b3bd6fcacmp4 ==> 19503b.mp4\n",
      "491abe26-f015-42c0-91a1-d492ad906mp4 ==> 491abe.mp4\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "\n",
    "path = '/Users/sinyeratlantis/Downloads/MP4/'\n",
    "\n",
    "prefix = path + os.sep  # os.sep添加系统分隔符\n",
    "\n",
    "files = os.listdir(path)  # 获取该目录下所有文件名，存入列表中\n",
    "\n",
    "n = 0\n",
    "for i in files:  # 输出检测下会不会出现改错名字的可能\n",
    "    oldname = files[n]\n",
    "    newname = files[n][:-30] + '.mp4'  # 更改后缀\n",
    "    \n",
    "    if oldname[0] != '.' and not os.path.isdir(prefix + oldname):  # 跳过隐藏文件和文件夹\n",
    "        print(oldname, '==>', newname)\n",
    "    \n",
    "    n += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "73eb3bc4-6ac1-4b65-9a66-150441f95mp4 ==> 73eb3b.mp4\n",
      "0c22b9ad-df4b-45ef-8cf2-1d8267f13mp4 ==> 0c22b9.mp4\n",
      "bcba9310-f2a3-4083-9f90-cb1ae4e93mp4 ==> bcba93.mp4\n",
      "5d1160cd-2637-4e75-a7bd-0e84f077dmp4 ==> 5d1160.mp4\n",
      "ce73e9bc-a2d2-4f4e-a818-449681f84mp4 ==> ce73e9.mp4\n",
      "f82b5f12-c90f-42a3-ab9c-fe0288786mp4 ==> f82b5f.mp4\n",
      "6c968c3f-58c5-474f-aaa0-1c5d51da3mp4 ==> 6c968c.mp4\n",
      "f393ce7d-7214-4b1a-83ab-ed17520a6mp4 ==> f393ce.mp4\n",
      "8cb7e9ed-8aa2-4070-a07e-a236ba8e1mp4 ==> 8cb7e9.mp4\n",
      "30ade32c-5c0c-44cd-b068-b010be38cmp4 ==> 30ade3.mp4\n",
      "9ea97401-2906-468d-be77-e7b324754mp4 ==> 9ea974.mp4\n",
      "528e6895-7a23-40b3-8b54-736bd94c6mp4 ==> 528e68.mp4\n",
      "3018ec91-5b15-44cd-8620-6466ab847mp4 ==> 3018ec.mp4\n",
      "19503be2-054b-4a3c-a92c-b3bd6fcacmp4 ==> 19503b.mp4\n",
      "491abe26-f015-42c0-91a1-d492ad906mp4 ==> 491abe.mp4\n"
     ]
    }
   ],
   "source": [
    "n = 0\n",
    "for i in files:\n",
    "    oldname = files[n]\n",
    "    newname = files[n][:-30] + '.mp4'\n",
    "    \n",
    "    if oldname[0] != '.' and not os.path.isdir(prefix + oldname):\n",
    "        os.rename(prefix + oldname, prefix + newname)  # rename方法\n",
    "        print(oldname, '==>', newname)\n",
    "    \n",
    "    n += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "os.remove(prefix + 'Thumbs')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
